package com.zmn.oms.third.taobao.service.impl;

import com.zmn.oms.common.constant.OrderConsts;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.entity.warn.OrderWarnReplyEvent;
import com.zmn.oms.third.taobao.TaobaoTmcConstants;
import com.zmn.oms.third.taobao.service.TmallService;
import com.zmn.oms.zmn.business.interfaces.open.OrderWarnReplyNotifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 类描述：
 *
 * @author LiangHailong
 * @date 2019/07/30 15:21
 */
@Service("tmallOrderWarnReplyNotifyService")
@Slf4j
public class TmallOrderWarnReplyNotifyServiceImpl implements OrderWarnReplyNotifyService {

    @Autowired
    private TmallService tmallService;

    @Override
    public void notifyOrderWarnReply(OrderWarnReplyEvent orderWarnReplyEvent) throws OmsBaseException {
        if (!TaobaoTmcConstants.POWER_ON) {
            log.info("【{}】<订单状态同步> 该功能没有开启。", TaobaoTmcConstants.NAME_TMALL);
            return;
        }

        // 管道订单不处理
        if (Objects.equals(OrderConsts.CHANNEL_ID_TMALL_PIPE, orderWarnReplyEvent.getChannelId())) {
            return;
        }

        tmallService.replyOrderWarn(orderWarnReplyEvent);
    }
}
